﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using Ue.Framework;
using Ue.Framework.Web.WebControls;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain.Tags;
using Ue.Qcdz.Domain.ContentTypes;
using Ue.Qcdz.UI;

namespace Ue.Qcdz.UI.Controls
{
    public class TagEdit : SkinnedEntityEdit<Tag>
    {
        private TextBox tbxTitle;
        private TextBox tbxDescription;

        protected override void InitSkin(System.Web.UI.Control skin)
        {
            tbxTitle = skin.FindControl<TextBox>("tbxTitle");
            tbxDescription = skin.FindControl<TextBox>("tbxDescription");
        }

        protected override string GetSkinFileName()
        {
            return "~/Admin/Themes/Skins/Tags/TagEdit.ascx";
        }

        protected override Tag Enttiy
        {
            get
            {
                return new Tag(this.EntityKey, this.ContentType)
                    {
                        Name = tbxTitle.GetValue<string>(),
                        Description = tbxDescription.GetValue<string>()
                    };
            }
            set
            {
                if (value == null)
                    return;

                this.ContentType = value.ContentType;
                tbxTitle.SetValue(value.Name);
                tbxDescription.SetValue(value.Description);
            }
        }

        public ContentType ContentType { get; set; }
    }
}
